home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / EDITIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  9.4 KB  |  390 lines

  1. unit EditImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib;
  8.  
  9. type
  10.   TEditX = class(TActiveXControl, IEditX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TEdit;
  14.     FEvents: IEditXEvents;
  15.     procedure ChangeEvent(Sender: TObject);
  16.     procedure ClickEvent(Sender: TObject);
  17.     procedure DblClickEvent(Sender: TObject);
  18.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  19.   protected
  20.     { Protected declarations }
  21.     procedure InitializeControl; override;
  22.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  23.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  24.     function Get_AutoSelect: WordBool; safecall;
  25.     function Get_AutoSize: WordBool; safecall;
  26.     function Get_CharCase: TxEditCharCase; safecall;
  27.     function Get_Color: TColor; safecall;
  28.     function Get_Ctl3D: WordBool; safecall;
  29.     function Get_Cursor: Smallint; safecall;
  30.     function Get_DragCursor: Smallint; safecall;
  31.     function Get_Enabled: WordBool; safecall;
  32.     function Get_Font: Font; safecall;
  33.     function Get_HideSelection: WordBool; safecall;
  34.     function Get_ImeName: WideString; safecall;
  35.     function Get_MaxLength: Integer; safecall;
  36.     function Get_Modified: WordBool; safecall;
  37.     function Get_OEMConvert: WordBool; safecall;
  38.     function Get_ParentColor: WordBool; safecall;
  39.     function Get_PasswordChar: Smallint; safecall;
  40.     function Get_ReadOnly: WordBool; safecall;
  41.     function Get_SelLength: Integer; safecall;
  42.     function Get_SelStart: Integer; safecall;
  43.     function Get_SelText: WideString; safecall;
  44.     function Get_Text: WideString; safecall;
  45.     function Get_Visible: WordBool; safecall;
  46.     procedure AboutBox; safecall;
  47.     procedure Clear; safecall;
  48.     procedure ClearSelection; safecall;
  49.     procedure CopyToClipboard; safecall;
  50.     procedure CutToClipboard; safecall;
  51.     procedure PasteFromClipboard; safecall;
  52.     procedure SelectAll; safecall;
  53.     procedure Set_AutoSelect(Value: WordBool); safecall;
  54.     procedure Set_AutoSize(Value: WordBool); safecall;
  55.     procedure Set_CharCase(Value: TxEditCharCase); safecall;
  56.     procedure Set_Color(Value: TColor); safecall;
  57.     procedure Set_Ctl3D(Value: WordBool); safecall;
  58.     procedure Set_Cursor(Value: Smallint); safecall;
  59.     procedure Set_DragCursor(Value: Smallint); safecall;
  60.     procedure Set_Enabled(Value: WordBool); safecall;
  61.     procedure Set_Font(const Value: Font); safecall;
  62.     procedure Set_HideSelection(Value: WordBool); safecall;
  63.     procedure Set_ImeName(const Value: WideString); safecall;
  64.     procedure Set_MaxLength(Value: Integer); safecall;
  65.     procedure Set_Modified(Value: WordBool); safecall;
  66.     procedure Set_OEMConvert(Value: WordBool); safecall;
  67.     procedure Set_ParentColor(Value: WordBool); safecall;
  68.     procedure Set_PasswordChar(Value: Smallint); safecall;
  69.     procedure Set_ReadOnly(Value: WordBool); safecall;
  70.     procedure Set_SelLength(Value: Integer); safecall;
  71.     procedure Set_SelStart(Value: Integer); safecall;
  72.     procedure Set_SelText(const Value: WideString); safecall;
  73.     procedure Set_Text(const Value: WideString); safecall;
  74.     procedure Set_Visible(Value: WordBool); safecall;
  75.   end;
  76.  
  77. implementation
  78. uses EditPg;
  79. { TEditX }
  80.  
  81. procedure TEditX.InitializeControl;
  82. begin
  83.   FDelphiControl := Control as TEdit;
  84.   FDelphiControl.OnChange := ChangeEvent;
  85.   FDelphiControl.OnClick := ClickEvent;
  86.   FDelphiControl.OnDblClick := DblClickEvent;
  87.   FDelphiControl.OnKeyPress := KeyPressEvent;
  88. end;
  89.  
  90. procedure TEditX.EventSinkChanged(const EventSink: IUnknown);
  91. begin
  92.   FEvents := EventSink as IEditXEvents;
  93. end;
  94.  
  95. procedure TEditX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  96. begin
  97.   { Define property pages here.  Property pages are defined by calling
  98.     DefinePropertyPage with the class id of the page.  For example,
  99.       DefinePropertyPage(Class_EditXPage); }
  100. end;
  101.  
  102. function TEditX.Get_AutoSelect: WordBool;
  103. begin
  104.   Result := FDelphiControl.AutoSelect;
  105. end;
  106.  
  107. function TEditX.Get_AutoSize: WordBool;
  108. begin
  109.   Result := FDelphiControl.AutoSize;
  110. end;
  111.  
  112. function TEditX.Get_CharCase: TxEditCharCase;
  113. begin
  114.   Result := Ord(FDelphiControl.CharCase);
  115. end;
  116.  
  117. function TEditX.Get_Color: TColor;
  118. begin
  119.   Result := FDelphiControl.Color;
  120. end;
  121.  
  122. function TEditX.Get_Ctl3D: WordBool;
  123. begin
  124.   Result := FDelphiControl.Ctl3D;
  125. end;
  126.  
  127. function TEditX.Get_Cursor: Smallint;
  128. begin
  129.   Result := Smallint(FDelphiControl.Cursor);
  130. end;
  131.  
  132. function TEditX.Get_DragCursor: Smallint;
  133. begin
  134.   Result := Smallint(FDelphiControl.DragCursor);
  135. end;
  136.  
  137. function TEditX.Get_Enabled: WordBool;
  138. begin
  139.   Result := FDelphiControl.Enabled;
  140. end;
  141.  
  142. function TEditX.Get_Font: Font;
  143. begin
  144.   GetOleFont(FDelphiControl.Font, Result);
  145. end;
  146.  
  147. function TEditX.Get_HideSelection: WordBool;
  148. begin
  149.   Result := FDelphiControl.HideSelection;
  150. end;
  151.  
  152. function TEditX.Get_ImeName: WideString;
  153. begin
  154.   Result := WideString(FDelphiControl.ImeName);
  155. end;
  156.  
  157. function TEditX.Get_MaxLength: Integer;
  158. begin
  159.   Result := FDelphiControl.MaxLength;
  160. end;
  161.  
  162. function TEditX.Get_Modified: WordBool;
  163. begin
  164.   Result := FDelphiControl.Modified;
  165. end;
  166.  
  167. function TEditX.Get_OEMConvert: WordBool;
  168. begin
  169.   Result := FDelphiControl.OEMConvert;
  170. end;
  171.  
  172. function TEditX.Get_ParentColor: WordBool;
  173. begin
  174.   Result := FDelphiControl.ParentColor;
  175. end;
  176.  
  177. function TEditX.Get_PasswordChar: Smallint;
  178. begin
  179.   Result := Smallint(FDelphiControl.PasswordChar);
  180. end;
  181.  
  182. function TEditX.Get_ReadOnly: WordBool;
  183. begin
  184.   Result := FDelphiControl.ReadOnly;
  185. end;
  186.  
  187. function TEditX.Get_SelLength: Integer;
  188. begin
  189.   Result := FDelphiControl.SelLength;
  190. end;
  191.  
  192. function TEditX.Get_SelStart: Integer;
  193. begin
  194.   Result := FDelphiControl.SelStart;
  195. end;
  196.  
  197. function TEditX.Get_SelText: WideString;
  198. begin
  199.   Result := WideString(FDelphiControl.SelText);
  200. end;
  201.  
  202. function TEditX.Get_Text: WideString;
  203. begin
  204.   Result := WideString(FDelphiControl.Text);
  205. end;
  206.  
  207. function TEditX.Get_Visible: WordBool;
  208. begin
  209.   Result := FDelphiControl.Visible;
  210. end;
  211.  
  212. procedure TEditX.AboutBox;
  213. begin
  214.   ShowEditXAbout;
  215. end;
  216.  
  217. procedure TEditX.Clear;
  218. begin
  219.  
  220. end;
  221.  
  222. procedure TEditX.ClearSelection;
  223. begin
  224.  
  225. end;
  226.  
  227. procedure TEditX.CopyToClipboard;
  228. begin
  229.  
  230. end;
  231.  
  232. procedure TEditX.CutToClipboard;
  233. begin
  234.  
  235. end;
  236.  
  237. procedure TEditX.PasteFromClipboard;
  238. begin
  239.  
  240. end;
  241.  
  242. procedure TEditX.SelectAll;
  243. begin
  244.  
  245. end;
  246.  
  247. procedure TEditX.Set_AutoSelect(Value: WordBool);
  248. begin
  249.   FDelphiControl.AutoSelect := Value;
  250. end;
  251.  
  252. procedure TEditX.Set_AutoSize(Value: WordBool);
  253. begin
  254.   FDelphiControl.AutoSize := Value;
  255. end;
  256.  
  257. procedure TEditX.Set_CharCase(Value: TxEditCharCase);
  258. begin
  259.   FDelphiControl.CharCase := TEditCharCase(Value);
  260. end;
  261.  
  262. procedure TEditX.Set_Color(Value: TColor);
  263. begin
  264.   FDelphiControl.Color := Value;
  265. end;
  266.  
  267. procedure TEditX.Set_Ctl3D(Value: WordBool);
  268. begin
  269.   FDelphiControl.Ctl3D := Value;
  270. end;
  271.  
  272. procedure TEditX.Set_Cursor(Value: Smallint);
  273. begin
  274.   FDelphiControl.Cursor := TCursor(Value);
  275. end;
  276.  
  277. procedure TEditX.Set_DragCursor(Value: Smallint);
  278. begin
  279.   FDelphiControl.DragCursor := TCursor(Value);
  280. end;
  281.  
  282. procedure TEditX.Set_Enabled(Value: WordBool);
  283. begin
  284.   FDelphiControl.Enabled := Value;
  285. end;
  286.  
  287. procedure TEditX.Set_Font(const Value: Font);
  288. begin
  289.   SetOleFont(FDelphiControl.Font, Value);
  290. end;
  291.  
  292. procedure TEditX.Set_HideSelection(Value: WordBool);
  293. begin
  294.   FDelphiControl.HideSelection := Value;
  295. end;
  296.  
  297. procedure TEditX.Set_ImeName(const Value: WideString);
  298. begin
  299.   FDelphiControl.ImeName := TImeName(Value);
  300. end;
  301.  
  302. procedure TEditX.Set_MaxLength(Value: Integer);
  303. begin
  304.   FDelphiControl.MaxLength := Value;
  305. end;
  306.  
  307. procedure TEditX.Set_Modified(Value: WordBool);
  308. begin
  309.   FDelphiControl.Modified := Value;
  310. end;
  311.  
  312. procedure TEditX.Set_OEMConvert(Value: WordBool);
  313. begin
  314.   FDelphiControl.OEMConvert := Value;
  315. end;
  316.  
  317. procedure TEditX.Set_ParentColor(Value: WordBool);
  318. begin
  319.   FDelphiControl.ParentColor := Value;
  320. end;
  321.  
  322. procedure TEditX.Set_PasswordChar(Value: Smallint);
  323. begin
  324.   FDelphiControl.PasswordChar := Char(Value);
  325. end;
  326.  
  327. procedure TEditX.Set_ReadOnly(Value: WordBool);
  328. begin
  329.   FDelphiControl.ReadOnly := Value;
  330. end;
  331.  
  332. procedure TEditX.Set_SelLength(Value: Integer);
  333. begin
  334.   FDelphiControl.SelLength := Value;
  335. end;
  336.  
  337. procedure TEditX.Set_SelStart(Value: Integer);
  338. begin
  339.   FDelphiControl.SelStart := Value;
  340. end;
  341.  
  342. procedure TEditX.Set_SelText(const Value: WideString);
  343. begin
  344.   FDelphiControl.SelText := String(Value);
  345. end;
  346.  
  347. procedure TEditX.Set_Text(const Value: WideString);
  348. begin
  349.   FDelphiControl.Text := TCaption(Value);
  350. end;
  351.  
  352. procedure TEditX.Set_Visible(Value: WordBool);
  353. begin
  354.   FDelphiControl.Visible := Value;
  355. end;
  356.  
  357. procedure TEditX.ChangeEvent(Sender: TObject);
  358. begin
  359.   if FEvents <> nil then FEvents.OnChange;
  360. end;
  361.  
  362. procedure TEditX.ClickEvent(Sender: TObject);
  363. begin
  364.   if FEvents <> nil then FEvents.OnClick;
  365. end;
  366.  
  367. procedure TEditX.DblClickEvent(Sender: TObject);
  368. begin
  369.   if FEvents <> nil then FEvents.OnDblClick;
  370. end;
  371.  
  372. procedure TEditX.KeyPressEvent(Sender: TObject; var Key: Char);
  373. var
  374.   TempKey: Smallint;
  375. begin
  376.   TempKey := Smallint(Key);
  377.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  378.   Key := Char(TempKey);
  379. end;
  380.  
  381. initialization
  382.   TActiveXControlFactory.Create(
  383.     ComServer,
  384.     TEditX,
  385.     TEdit,
  386.     Class_EditX,
  387.     8,
  388.     '{5A565981-7975-11D0-BE02-00A024D1875C}');
  389. end.
  390.